<template>
  <div class="twoxm-detail">
      <mt-swipe :auto="4000">
      <mt-swipe-item
        v-for=" photo in detail.photo"
        :key="photo.id"
      >
        <img :src="photo.url" alt="">
      </mt-swipe-item>
      </mt-swipe>
      <h4>{{ detail.title }}</h4>
      <p class="twoxm-detail-jg">￥{{ detail.price }}</p>
      <div class="twoxm-detail-xl">
        <p>原价￥<span>{{ detail.tbOriginPrice }}</span></p>
        <p>销量:{{ detail.saleNum }}</p>
      </div>
      <div class="twoxm-detail-cart">
         <van-goods-action>
          <van-goods-action-icon icon="chat-o" text="客服" />
          <van-goods-action-icon icon="shop-o" text="店铺" />
          <van-goods-action-button color="#ff5000" type="warning" text="加入购物车" to="/cart" />
          <van-goods-action-button color="#7232dd" type="danger" text="立即购买" />
        </van-goods-action>
      </div>
  </div>
</template>

<script>
export default {
  name: 'detail',
  data () {
    return {
      detail: {}
    }
  },
  created () {
    const { id } = this.$route.query
    this.$http.getDetail(id)
      .then(resp => {
        const {
          id,
          photo,
          price,
          title,
          saleNum,
          tbOriginPrice,
          descContentList
        } = resp.detail
        this.detail = { id, photo, price, title, saleNum, descContentList, tbOriginPrice }
      })
  }
}
</script>

<style lang="scss">
.twoxm-detail {
  overflow-x: hidden;
  height: 100%;
  width: 100%;
  .mint-swipe {
    width: 100%;
    padding-top: 100%;
    height: 0;
    position: relative;
    .mint-swipe-items-wrap {
      width: 100%;
      position: absolute;
      top: 0;
      left: 0;
      img {
        width: 100%;
      }
    }
  }
  &-xl {
    border-bottom: 1px solid #ccc;
    display: flex;
    justify-content: space-between;
    color: red;
    font-size: 15px;
    span {
      text-decoration: line-through;
    }
  }
  h4 {
    text-align: center;
    font-size: 20px;
  }
  &-jg {
    line-height: 40px;
    font-size: 15px;
    color: #f40;
  }
}
</style>
